<?php
/******************************************************
v4 - Management Framework
Copyright (C) 2008  Gary Taylor, gMerc Incorporation
http://www.gmerc.com/v4/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

gary@gmerc.com
******************************************************/
class makepayment {
  function loaddata() {
    global $masterclass;

    $masterclass->loadmodule('customers');
    $masterclass->loadmodule('personnel');
    $masterclass->loadmodule('invoices');
    $masterclass->loadmodule('companies');
    $masterclass->loadmodule('payments');
    $masterclass->loadmodule('captcha',$masterclass->mainconfig['v4rootdir'].'lib/captcha.lib.php');

    $masterclass->loadjavascript('invoices');

    $masterclass->websiteconfig['javascript_include'][]='include/date-picker.js';
    
    $masterclass->loadjavascript('',$masterclass->mainconfig['v4rootdir'].'include/suckertreemenu.inc.js');
    
    $masterclass->site['postfields'][] = array(
      'trackingid'=>'paymentid'
    );
    $masterclass->site['postfields'][] = array(
      'trackingid'=>'customerid'
    );
    $masterclass->site['postfields'][] = array(
      'trackingid'=>'invoicesid'
    );

    if ($masterclass->sitevars['customerid']!='') {
      $masterclass->site['invoices_customertotals']=$masterclass->allclasses['payments']->fetch_customer_payments($masterclass->sitevars['customerid']);
    }
    
  return;
  }
  
  function savedata() {
    global $masterclass;
    
    if (isset($masterclass->sitevars['invoices_payment_date']) && $masterclass->sitevars['invoices_payment_date']!='') {
      $invoices_payment_date=$masterclass->sitevars['invoices_payment_date'];
    } else {
       $invoices_payment_date=date("Y-m-d"); 
    }
    
    if ($strwhere!='') { $strwhere.=' AND '; }
    $strwhere.=" (`active`='1') AND (`documenttype`='invoice') AND (`paid`='0000-00-00') ";
    if ($masterclass->sitevars['customerid']!='') {
      if ($strwhere!='') { $strwhere.=' AND '; }
      $strwhere.=sprintf(" (`customer`=%d) ",$masterclass->format_dbl($masterclass->sitevars['customerid']));
    }
    $listarray=$masterclass->fetch_records('`invoices_documents`','',$strwhere,'');
    
    $amt=$masterclass->allclasses['payments']->calc_payment_amt($masterclass->sitevars['invoices_payment_amount'],$masterclass->sitevars['invoices_paymenttype']);                
    $masterclass->sitevars['paymentid']=$masterclass->allclasses['payments']->add_payment($amt,$masterclass->sitevars['invoicesid'],$masterclass->sitevars['invoices_paymenttype'],$invoices_payment_date);

    while (!$listarray->EOF) {
      $masterclass->site['invoices_paymenttotals']=array();
      $masterclass->site['invoices_documenttotals']=array();
      
      if (isset($masterclass->sitevars['invoices_payment_selectedinvoice_'.$listarray->fields['id']]) && $masterclass->sitevars['invoices_payment_selectedinvoice_'.$listarray->fields['id']]!='') {
        
        $masterclass->site['invoices_paymenttotals']=$masterclass->allclasses['payments']->calc_payment_totals($listarray->fields['id']);
        $masterclass->site['invoices_documenttotals']=$masterclass->allclasses['payments']->calc_payment_documents($listarray->fields['id']);
        $masterclass->site['invoices_paymenttotals']['totalpayments']+=$masterclass->site['invoices_documenttotals']['totaldocumentpayments'];

        $amt=$masterclass->sitevars['invoices_payment_selectedinvoice_'.$listarray->fields['id']];
        if (money_format("%i",$amt)>(money_format("%i",$masterclass->site['invoices_documenttotals']['total_invoice_total'])-money_format("%i",$masterclass->site['invoices_paymenttotals']['totalpayments']))) {
          $amt=money_format("%i",$masterclass->site['invoices_documenttotals']['total_invoice_total'])-money_format("%i",$masterclass->site['invoices_paymenttotals']['totalpayments']);
        } else if (money_format("%i",$amt)==(money_format("%i",$masterclass->site['invoices_documenttotals']['total_invoice_total'])-money_format("%i",$masterclass->site['invoices_paymenttotals']['totalpayments']))) {
          $amt=money_format("%i",$amt);
        } else if (money_format("%i",$amt)<(money_format("%i",$masterclass->site['invoices_documenttotals']['total_invoice_total'])-money_format("%i",$masterclass->site['invoices_paymenttotals']['totalpayments']))) {
          $amt=money_format("%i",$amt);
        }

        $masterclass->allclasses['payments']->add_payment_documents($amt,$masterclass->sitevars['paymentid'],$listarray->fields['id']);

        if ((money_format("%i",$masterclass->site['invoices_paymenttotals']['totalpayments'])+money_format("%i",$amt))>=money_format("%i",$masterclass->site['invoices_documenttotals']['total_invoice_total'])) {
          $masterclass->allclasses['payments']->mark_invoice_paid($listarray->fields['id'],$invoices_payment_date);
        }
        
      }
      
    $listarray->MoveNext();
    }
        
    $masterclass->site['forward']='window.close();';
    
  return;
  }
  function display_invoices($customerid='') {
    global $masterclass;

    if ($pg<0) { $pg=1; }

    if ($strwhere!='') { $strwhere.=' AND '; }
    $strwhere.=" (`active`='1') AND (`documenttype`='invoice') AND (`paid`='0000-00-00') ";
    if ($customerid!='') {
      if ($strwhere!='') { $strwhere.=' AND '; }
      $strwhere.=sprintf(" (`customer`=%d) ",$customerid);  
    }

    $listcnt=$masterclass->fetch_recordcount('invoices_documents',$strwhere);
    $listarray=$masterclass->fetch_records('`invoices_documents`','',$strwhere,' ABS(`documentid`) DESC, `documentdate` DESC, `updated` DESC ');

    $ret='';
    $amountfields='';

    $ret.='<table width="100%" align="center" cellpadding="0" cellspacing="0" class="sitebox_content">';
    $ret.='<tr valign="top" class="sitebox_content" style="cursor:pointer;">';
    $ret.='<td width="20" valign="middle" style="padding-left:3px;text-align:center;border-bottom:1px solid;"><nobr>PAY AMT</nobr></td>';
  
    //$ret.='<td width="75" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>TOTAL</nobr></td>';
    $ret.='<td width="75" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>OWED</nobr></td>';
    $ret.='<td colspan="2" valign="middle" style="padding-left:3px;text-align:right;border-bottom:1px solid;"><nobr>ID</nobr>&nbsp;&nbsp;</td>';
    $ret.='<td valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>DUE DATE</nobr>&nbsp;</td>';
    $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:center;border-bottom:1px solid;">OPEN</td>';
    $ret.='</tr>';
    if (empty($listarray->fields)) {
      $ret.='<tr valign="top">';
      $ret.='<td width="100%" valign="middle" style="padding-left:2px;text-align:center;" colspan="5">No Invoices</td>';
      $ret.='</tr>';
    } else {
      while (!$listarray->EOF) {
          
        $totalpayments=0;
        $arrinvoicepayments=$masterclass->allclasses['payments']->fetch_invoices_payments($listarray->fields['id']);
        if (!empty($arrinvoicepayments)) { foreach ($arrinvoicepayments as $invpayment) { $totalpayments+=money_format("%i",$invpayment['invoicepayment']); } }
        $arrinvoicetotals=$masterclass->allclasses['invoices']->fetch_invoices_totals($listarray->fields['id']);
        
        $openclick=' OnClick="openwindow(\''.$masterclass->mainconfig['dir'].$masterclass->mainconfig['htmldirectory'].'invoices/showinvoice.php?invoicesid='.$listarray->fields['id'].'\',\'invoices_show'.$listarray->fields['id'].'\',\'760\',\'600\');" ';
        if (money_format("%i",$arrinvoicetotals['total'])>money_format("%i",$totalpayments)) {
          $ret.='<tr valign="top" class="sitebox_content" style="cursor:pointer;">';
          $ret.='<td width="20" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><nobr>$'.$masterclass->allclasses['websites']->disp_inputtext('invoices_payment_selectedinvoice_'.$listarray->fields['id'],'65','12','10','','','invoices_payment_divytotals();');
          $ret.='<input type="button" class="button" value="Pay" OnClick="document.getElementById(\'invoices_payment_selectedinvoice_'.$listarray->fields['id'].'\').value=\''.money_format("%i",(money_format("%i",$arrinvoicetotals['total'])-money_format("%i",$totalpayments))).'\';invoices_payment_divytotals();"></nobr></td>';
          //$ret.='<td width="75" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>$'.number_format($arrinvoicetotals['total'],2).'</nobr>&nbsp;&nbsp;</td>';
          $ret.='<td width="75" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>$'.number_format((money_format("%i",$arrinvoicetotals['total'])-money_format("%i",$totalpayments)),2).'&nbsp;</nobr>&nbsp;&nbsp;</td>';
          $ret.='<td width="15" valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>';
          if (money_format("%i",$totalpayments)>0) {
            $ret.=abs(round((money_format("%i",$totalpayments)/money_format("%i",$arrinvoicetotals['total']))*100)-100);
          } else {
            $ret.='100';
          }
          $ret.='%</nobr>&nbsp;&nbsp;</td>';
          $ret.='<td width="15" valign="middle" style="padding-left:3px;text-align:left;border-bottom:1px solid;"><nobr>#'.$listarray->fields['documentid'].'</nobr>&nbsp;&nbsp;</td>';
          $ret.='<td valign="middle" style="padding-left:2px;padding-right:2px;text-align:right;border-bottom:1px solid;"><nobr>'.date("m-d-Y",strtotime($listarray->fields['duedate'])).'</nobr>&nbsp;</td>';
          $ret.='<td '.$openclick.' width="20" valign="middle" style="padding-left:3px;text-align:center;border-bottom:1px solid;border-right:1px solid;cursor:pointer;"><img src="'.$masterclass->mainconfig['dir'].'art/book_go.png" border="0" alt="Open" title=" Open "></td>';

          $ret.='</tr>';
        
          if ($amountfields!='') { $amountfields.=','; }
          $amountfields.='invoices_payment_selectedinvoice_'.$listarray->fields['id'].':'.money_format("%i",(money_format("%i",$arrinvoicetotals['total'])-money_format("%i",$totalpayments)));
        }
        
      $listarray->MoveNext();
      }
    }
    $ret.='</table>';
    $ret.='<script language="javascript">var invoices_payment_amountfields=\''.$amountfields.'\';</script>';
  return $ret;
  }

  function display_invoices_itemslist($containername='',$invoicesid='') {
    global $masterclass;

    if (isset($_POST['rsargs']) && !empty($_POST['rsargs'])) {
      $containername=$_POST['rsargs'][1];
      $invoicesid=$_POST['rsargs'][2];
    }

    $listarray=$masterclass->allclasses['invoices']->fetch_invoices_items($invoicesid,$strwhere,' `datestamp` ');
    //$listdisplay=$masterclass->allclasses['invoices']->display_invoices_items($listarray);

    $ret='';
    if (empty($listarray->fields)) {
      $ret.='<table width="100%" align="center" cellpadding="0" cellspacing="0" class="sitebox_content">';
      $ret.='<tr valign="top">';
      $ret.='<td width="100%" valign="middle" style="padding-left:2px;text-align:center;">No Items</td>';
      $ret.='</tr>';
      $ret.='</table>';
    } else {
      $arrinvoicetotal=$masterclass->allclasses['invoices']->calc_invoicetotal($listarray);

      $ret.='<table width="100%" align="center" cellpadding="1" cellspacing="0" class="sitebox_content">';
      $ret.='<tr valign="top" class="sitebox_navigation">';
      $ret.='<td style="text-align:right;" ><nobr>&nbsp;<b>Item Count</b></nobr></td>';
      $ret.='<td style="text-align:right;" ><nobr>&nbsp;<b>SubTotal</b></nobr></td>';
      $ret.='<td style="text-align:right;" ><nobr>&nbsp;<b>Tax</b></nobr></td>';
      $ret.='<td style="text-align:right;" ><nobr>&nbsp;<b>Total</b></nobr></td>';
      $ret.='</tr>';
      $ret.='<tr valign="top" class="sitebox_navigation">';
      $ret.='<td style="text-align:right;border-bottom:1px solid;" ><nobr>&nbsp;<b>'.number_format($arrinvoicetotal['qty'],0).'</b></nobr></td>';
      $ret.='<td style="text-align:right;border-bottom:1px solid;" ><nobr>&nbsp;<b>$'.number_format($arrinvoicetotal['subtotal'],2).'</b></nobr></td>';
      $ret.='<td style="text-align:right;border-bottom:1px solid;" ><nobr>&nbsp;<b>$'.number_format($arrinvoicetotal['tax'],2).'</b></nobr></td>';
      $ret.='<td style="text-align:right;border-bottom:1px solid;" ><nobr>&nbsp;<b>$'.number_format($arrinvoicetotal['total'],2).'</b></nobr></td>';
      $ret.='</tr>';
      $ret.='</table>';


      $ret.='<table width="100%" align="center" cellpadding="1" cellspacing="0" class="sitebox_content">';
      $ret.='<tr valign="top" class="sitebox_navigation">';
      $ret.='<td style="border-right:1px solid;border-bottom:2px solid;"><nobr>&nbsp;<b>Name</b></nobr></td>';
      $ret.='<td width="15" style="text-align:center;border-right:1px solid;border-bottom:2px solid;"><nobr>&nbsp;<b>Qty</b></nobr></td>';
      $ret.='<td width="20" style="text-align:center;border-right:1px solid;border-bottom:2px solid;" ><nobr>&nbsp;<b>SubTotal</b></nobr></td>';
      $ret.='<td width="30" style="text-align:center;border-right:1px solid;border-bottom:2px solid;"><nobr>&nbsp;<b>Tax&nbsp;</b></nobr></td>';
      $ret.='<td width="30" style="padding-right:1px;text-align:right;border-bottom:2px solid;"><nobr>&nbsp;<b>Total</b></nobr></td>';
      $ret.='</tr>';

      foreach ($listarray as $result) {
        $pname='';
        $profile='';
        if ($listedids!='') { $listedids.=','; } $listedids.=$result['id'];

        if (date("Y-m-d")==date("Y-m-d",strtotime($result['updated']))) {
          $pstamp = date("H:m:s",strtotime($result['updated']));
        } else {
          $pstamp = date("Y-m-d",strtotime($result['updated']));
        }

        if (preg_match('/^[0-9.-]+$/iD', $result['qty'])) { $qty=$result['qty']; } else { $qty=1; }
        if (preg_match('/^[0-9.-]+$/iD', $result['cost'])) { $cost=$result['cost']; } else { $cost=0; }
        if (preg_match('/^[0-9.-]+$/iD', $result['taxpercent'])) { $taxpercent=$result['taxpercent']; } else { $taxpercent=0; }

        if ($cost<0) { $polarity='-'; } else { $polarity='+'; }

        $subtotal=$qty*abs($cost);
        $taxcost=$subtotal*($taxpercent/100);
	$total=$taxcost+$subtotal;

        $profile_mouseover='OnMouseOver="document.getElementById(\'invoices_itemsbrief'.$result['id'].'\').className=\'sitebox_content_mouseover\';document.getElementById(\'invoices_itemsdesc'.$result['id'].'\').className=\'sitebox_content_mouseover\';" OnMouseOut="document.getElementById(\'invoices_itemsbrief'.$result['id'].'\').className=\'sitebox_content\';document.getElementById(\'invoices_itemsdesc'.$result['id'].'\').className=\'sitebox_content\';"';

        $profile.='<tr id="invoices_itemsbrief'.$result['id'].'" valign="top" class="sitebox_content" '.$profile_mouseover.'>';

        $profile.='<td style="text-align:left;cursor:pointer;padding-top:1px;padding-left:2px;padding-bottom:1px;cursor:pointer;border-right:1px solid;">'.$result['name'].'</td>';

        //$qtyonclick='OnClick="hide(document.getElementById(\'invoices_edititem_qtytext_'.$result['id'].'\'));show(document.getElementById(\'invoices_edititem_qtyinput_'.$result['id'].'\'));document.getElementById(\'invoices_edititem_qty\').focus();"';
        $profile.='<td '.$qtyonclick.' width="10" style="text-align:left;padding-top:1px;padding-bottom:1px;cursor:pointer;border-right:1px solid;border-bottom:1px solid;" ><span id="invoices_edititem_qtytext_'.$result['id'].'"><nobr>&nbsp;'.$result['qty'].'</nobr></span><span id="invoices_edititem_qtyinput_'.$result['id'].'" style="display:none;"><input OnFocus="this.select()" style="text-align:right;" type="text" size="3" name="invoices_edititem_qty" id="invoices_edititem_qty" value="'.$result['qty'].'" class="sitebox_content"></span></td>';

        $profile.='<td width="20" style="text-align:right;padding-top:1px;padding-bottom:1px;cursor:pointer;border-right:1px solid;border-bottom:1px solid;" align="right" '.$profile_onclick_open.'><nobr>&nbsp;';
        if (preg_match('/^[0-9.-]+$/iD', $subtotal)) { $profile.='$'.number_format($subtotal,2); } else { $profile.=$subtotal; }
        $profile.='</nobr></td>';
        $profile.='<td width="30" style="text-align:right;padding-top:1px;padding-bottom:1px;cursor:pointer;border-right:1px solid;border-bottom:1px solid;" align="right" '.$profile_onclick_open.'><nobr>&nbsp;';
        if ($result['taxed']=='1') {
	  if (preg_match('/^[0-9.-]+$/iD', $taxcost)) { $profile.='$'.number_format($taxcost,2).' '; } else { $profile.=$taxcost.' '; }
        } else {
	  $profile.='$0.00 ';
	}
        $profile.='&nbsp;';
	if ($result['taxed']=='1') { $profile.=$taxpercent; } else { $profile.='0'; }
	$profile.='%</nobr></td>';
        $profile.='<td width="30" style="text-align:right;padding-top:1px;padding-bottom:1px;cursor:pointer;border-bottom:1px solid;" align="right" '.$profile_onclick_open.'><nobr>&nbsp;';
        if (preg_match('/^[0-9.-]+$/iD', $total)) { $profile.='$'.number_format($total,2); } else { $profile.=$total; }
        $profile.='</nobr></td>';

        $profile.='</tr>';

        if ($result['description']!='') {
	  $profile.='<tr id="invoices_itemsdesc'.$result['id'].'" '.$profile_mouseover.' style="cursor:pointer;" '.$profile_onclick_open.'>';
	  $profile.='<td colspan="7" style="border-bottom:2px solid;">'.nl2br($result['description']).'</td>';
	  $profile.='</tr>';
        } else {
	  $profile.='<tr id="invoices_itemsdesc'.$result['id'].'" '.$profile_mouseover.' style="cursor:pointer;border-bottom:1px solid;" '.$profile_onclick_open.'>';
	  $profile.='<td colspan="7" style="border-bottom:2px solid;font-size:2px;">&nbsp;&nbsp;</td>';
	  $profile.='</tr>';
        }

        $ret.=$profile;
      }
      $ret.='</table>';
    }

    $masterclass->site['grabdata_vars']['load_list']=$ret;
    $masterclass->site['grabdata_vars']['load_containername']=$containername;

  return $ret;
  }

  function display() {
    global $masterclass;

  if (!isset($masterclass->sitevars['invoices_payment_date'])) { $masterclass->sitevars['invoices_payment_date']=date("Y/m/d"); }
  
  if (isset($masterclass->sitevars['customerid']) && $masterclass->sitevars['customerid']!='') {
    $strwhere=sprintf(" `id`=%d ",$masterclass->format_dbl($masterclass->sitevars['customerid']));
    $customerinfo=$masterclass->fetch_records('`customers`',1,$strwhere,'',1);
    if (!empty($customerinfo->fields)) {
     $masterclass->sitevars['invoices_recipientlineone']=$customerinfo->fields['first'].' '.$customerinfo->fields['last'];
     $masterclass->sitevars['invoices_recipientlinetwo']=$customerinfo->fields['address'];
     $masterclass->sitevars['invoices_recipientlinethree']=$customerinfo->fields['city'].', '.$customerinfo->fields['state'].'  '.$customerinfo->fields['zip'];
     $masterclass->sitevars['invoices_recipientlinefour']=$customerinfo->fields['emaila'];
     $masterclass->sitevars['invoices_recipientlinefive']=$customerinfo->fields['dayphone'];
    }
  } else
  if (isset($masterclass->sitevars['invoicesid']) && $masterclass->sitevars['invoicesid']!='') {
    $strwhere=sprintf(" `id`=%d ",$masterclass->format_dbl($masterclass->sitevars['invoicesid']));
    $invoiceinfo=$masterclass->fetch_records('`invoices_documents`',1,$strwhere,'',1);
    if (!empty($invoiceinfo->fields)) {
     $masterclass->sitevars['invoices_recipientlineone']=$invoiceinfo->fields['recipientlineone'];
     $masterclass->sitevars['invoices_recipientlinetwo']=$invoiceinfo->fields['recipientlinetwo'];
     $masterclass->sitevars['invoices_recipientlinethree']=$invoiceinfo->fields['recipientlinethree'];
     $masterclass->sitevars['invoices_recipientlinefour']=$invoiceinfo->fields['recipientlinefour'];
     $masterclass->sitevars['invoices_recipientlinefive']=$invoiceinfo->fields['recipientlinefive'];
    }
  }
  
  
  $pageheader='<table width="100%" cellpadding="0" cellspacing="0" border="0" class="sitebox_pageheader"><tr>';
  $pageheader.='<td style="text-align:left;">'.$masterclass->sitevars['invoices_recipientlineone'].'</td>';
  $pageheader.='<td style="text-align:right;" width="25"><nobr>PAYMENT</nobr></td>';
  $pageheader.='</tr></table>';
  echo $masterclass->allclasses['websites']->sitebox_pageheader($pageheader,'');


$nav='';
$nav.='<div class="sitebox_navigation" style="width:100%;">';
$nav.='<ul id="sitebox_navmenu">';
$nav.='<li OnClick="if (invoices_payment_checkagainstamt()==true) { captcha_action(\'document.getElementById(\\\'frm\\\').submit();\'); }"><a>Submit Payment</a></li>';
$nav.='<li OnClick="window.close();"><a>Cancel Payment</a></li>';
$nav.='</ul>';
$nav.='<br style="clear: left;" />';
$nav.='</div>';
echo $nav;
?>
<table width="100%" cellpadding="2" cellspacing="5" border="0">
  <tr valign="top">
  <td width="40%">
<?php
if (isset($masterclass->sitevars['customerid']) && $masterclass->sitevars['customerid']!='') {
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Billing Information','');
?>
<table width="100%" align="center" cellpadding="0" cellspacing="1" class="sitebox_content">
  <tr valign="top">
    <td width="95%"><b>Customer:</b></td>
  </tr>
  <tr valign="top">
    <td width="95%">&nbsp;&nbsp;<?php echo $masterclass->allclasses['websites']->disp_text('invoices_recipientlineone');?></td>
  </tr>
  <tr valign="top">
    <td width="95%">&nbsp;&nbsp;<?php echo $masterclass->allclasses['websites']->disp_text('invoices_recipientlinetwo');?></td>
  </tr>
  <tr valign="top">
    <td width="95%">&nbsp;&nbsp;<?php echo $masterclass->allclasses['websites']->disp_text('invoices_recipientlinethree');?></td>
  </tr>
  <tr valign="top">
    <td width="95%">&nbsp;&nbsp;<?php echo $masterclass->allclasses['websites']->disp_text('invoices_recipientlinefour');?></td>
  </tr>
  <tr valign="top">
    <td width="95%">&nbsp;&nbsp;<?php echo $masterclass->allclasses['websites']->disp_text('invoices_recipientlinefive');?></td>
  </tr>
</table>
<?php
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
  echo $masterclass->allclasses['websites']->sitebox_vspacer(5);
}


/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Payment Information','');

  echo $masterclass->allclasses['payments']->display_payment();
  
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
  echo $masterclass->allclasses['websites']->sitebox_vspacer(5);

?>
</td><td width="60%">
<?php
//if ((isset($masterclass->sitevars['customerid']) && $masterclass->sitevars['customerid']!='')) {

/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('UnPaid Invoices','');
  
  $nav='';
  $nav.='<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr valign="middle" class="sitebox_navigation">';
  $nav.='<td id="invoices_payment_totaldivy" style="font-weight:800;">';
  $nav.='$0.00';
  $nav.='</td>';
  $nav.='</tr></table>';
  echo $masterclass->allclasses['websites']->sitebox_navigation($nav);
  
?>
<div class="sitebox_content"><?php echo $this->display_invoices($masterclass->sitevars['customerid']); ?></div>
<?php
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
  echo $masterclass->allclasses['websites']->sitebox_vspacer(5);
//}

if (isset($masterclass->sitevars['invoicesid']) && $masterclass->sitevars['invoicesid']!='') {
/* Start Window */
  echo $masterclass->allclasses['websites']->sitebox_start('100%');
  echo $masterclass->allclasses['websites']->sitebox_headline('Invoice Items','');
?>
<div><?php echo $this->display_invoices_itemslist($unquieid,$masterclass->sitevars['invoicesid']); ?></div>
<?php
  echo $masterclass->allclasses['websites']->sitebox_end();
/* End Window */
  echo $masterclass->allclasses['websites']->sitebox_vspacer(5);
}
?>
</td></tr></table>
<?php

  return;
  }
}
?>